home *** CD-ROM | disk | FTP | other *** search
- ;==============================================================[ Description ]=
-
- ; This is an example of source containing Exec's _LVOPutMsg() routine,
- ; which you can use to put a message to a port.
- ; In this case, program looks for port called "Amsterdam" (or anything
- ; you want 8), and if it finds, then send a message. You should earlier
- ; run another source, that creates port "Amsterdam" (it's WaitPort.s).
- ; You can type some texts after PutMsg program (as parameters) and the
- ; task waiting for this message will print it on the console.
-
- ; $VER: PutMsg.s V1.1 (30.10.94)
- ; Source by Cromax of Alchemy (kita@sun10.ci.pwr.wroc.pl)
-
- ;===================================================================[ Values ]=
-
- ExecBase Equ 4
-
- _LVOFindTask Equ -294
- _LVOFindPort Equ -390
- _LVOForbid Equ -132
- _LVOPermit Equ -138
- _LVOPutMsg Equ -366
- _LVOWaitPort Equ -384
-
- NT_MSGPORT Equ 4
- NT_MESSAGE Equ 5
-
- lh_TailPred Equ 008
-
- mp_SigTask Equ 016
- mp_MsgList Equ 020
-
- mymsg_Length Equ 4 ; Offsets of our message
- mymsg_String Equ 8 ; defined by myself
-
- ;=============================================================[ Main Program ]=
-
- Section PutMessage,Code_P
-
- Begin: bra.s .Skip
-
- dc.b "$VER: PutMsg V1.1 (30.10.94)",10,0
- even
-
- .Skip: lea Message,a1
- adda.l #20,a1 ; Fill our message structure
- move.l d0,mymsg_Length(a1) ; with length of parameter
- move.l a0,mymsg_String(a1) ; string and pointer to it
-
- movea.l [ExecBase].w,a6 ; I'm not quiet sure you have
- jsr _LVOForbid(a6) ; to use Forbid/Permit here...
-
- movea.l [ExecBase].w,a6 ; Find pointer to Task
- suba.l a1,a1 ; structure of our task
- jsr _LVOFindTask(a6) ; (if a1=NULL)
- move.l d0,_Task
- beq.w Permit
-
- lea MsgPort,a0 ; Complete MsgPort structure
- move.l d0,mp_SigTask(a0) ; If we didn't found anything
- adda.l #mp_MsgList,a0 ; Set pointers of List struct
- move.l a0,lh_TailPred(a0) ; in MsgPort structure
- addq #4,a0 ; Get addres of lh_Tail
- clr.l (a0) ; Clear lh_Tail
- move.l a0,-(a0) ; Address of lh_Tail to lh_Head
-
- movea.l [ExecBase].w,a6 ; If you want to put a message
- lea DestPortName,a1 ; to a public port, then here
- jsr _LVOFindPort(a6) ; we'll find its address using
- move.l d0,_DestinyPort ; its name
- beq.s Permit ; If port doesn't exist, then
- ; quit
- movea.l [ExecBase].w,a6 ; In a0 we place address of
- movea.l d0,a0 ; MsgPort to send a message to
- lea Message,a1 ; (if port isn't public, we
- jsr _LVOPutMsg(a6) ; have to know its address
- ; earlier)
- Permit: movea.l [ExecBase].w,a6 ; Enable multitaksing...
- jsr _LVOPermit(a6)
-
- tst.l _DestinyPort
- beq.s End
- movea.l [ExecBase].w,a6 ; Wait for reply message...
- lea MsgPort,a0
- jsr _LVOWaitPort(a6)
-
- End: moveq #0,d0
- rts
-
- ;=====================================================================[ Data ]=
-
- Section Data,Data_P
-
- MsgPort: dc.l 0 ; ln_Succ
- dc.l 0 ; ln_Pred
- dc.b NT_MSGPORT ; ln_Type
- dc.b 0 ; ln_Pri
- dc.l 0 ; ln_Name
- dc.b 0 ; mp_Flags
- dc.b 0 ; mp_SigBits
- dc.l 0 ; mp_SigTask
- dc.l 0 ; lh_Head
- dc.l 0 ; lh_Tail
- dc.l 0 ; lh_TailPred
- dc.b 0 ; lh_Type
- dc.b 0 ; lh_pad
-
- Message: dc.l 0 ; ln_Succ
- dc.l 0 ; ln_Pred
- dc.b NT_MESSAGE ; ln_Type
- dc.b 0 ; ln_Pri
- dc.l 0 ; ln_Name
- dc.l MsgPort ; mn_ReplyPort
- dc.w 32 ; mn_Length (20b + 12b of our msg)
- ;······················ ; Here begins our message
- dc.l "CRMX" ; mymsg_IDHeader
- dc.l 0 ; mymsg_Length
- dc.l 0 ; mymsg_String
-
- DestPortName: dc.b "Amsterdam",0
-
- ;=====================================================================[ Vars ]=
-
- Section Vars,Bss
-
- _DestinyPort: ds.l 1
- _Task: ds.l 1
-